package com.jiangruan.project.service;

import com.alibaba.fastjson.JSONObject;
import com.jiangruan.project.Constants;
import com.jiangruan.project.bean.HotVideo;
import com.jiangruan.project.bean.HotVideoComm;
import com.jiangruan.project.request.HttpUtils;

import java.util.List;

/**
 * @author:liangdu
 * @email:1487001474@qq.com
 * @desc:
 * @datetime: 2021/12/12 20:32
 */
public class HotVideoService {
    /**
     * 该方法用于获取热门数据，并将热门数据返回
     * @return
     */
    public List<HotVideo> getHotVideo(){
        String url = Constants.TRIP_URL
                + "?key=" + Constants.TRIP_KEY
                + "&type=hot_video"
                + "&size=20";
        String result = HttpUtils.get(url);
        System.out.println(result);

        //json解析
        HotVideoComm videoComm= JSONObject.parseObject(result, HotVideoComm.class);


        return videoComm.result;
    }
}
